%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                          %%
%%  Auteur : Joe R. Nassimian                            2010-06-17         %%
%%                                                                          %%
%%  Latex document class for my internship report.                          %%
%%                                                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{**** Class written for the internship at CITI Lab, INSA Lyon *****}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

% Identification
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{internship-report}[2010/06/17]

% Preliminary Declarations
\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{***************** Overloading class [report] *********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\LoadClass[a4paper,12pt]{report}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{****************** Loading required Packages *********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

%-------------------------------------------------------------------------------
%                required packages
%-------------------------------------------------------------------------------
\RequirePackage{ifthen}
\RequirePackage{ifpdf}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage[francais]{babel}
\RequirePackage[french]{varioref}
\RequirePackage{indentfirst}
\RequirePackage{makeidx}
\RequirePackage[dvips]{color}
\RequirePackage{graphics,graphicx}
\RequirePackage{caption}
\RequirePackage{myprettyref}
\RequirePackage{times}
\RequirePackage{pst-grad}
\RequirePackage{fancyhdr}
\RequirePackage[final]{pdfpages}
%\RequirePackage{fullpage}
\RequirePackage{rotating}
\RequirePackage{listings}
\RequirePackage{color}
\graphicspath{{fig/}{graphics/}}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{***************** Loading user data & meta-info ******************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\include{userdata}

% hyperrefs
\RequirePackage{url}


\ifpdf
  \RequirePackage[
      pdftex,
      pagebackref=true,
      colorlinks=true,
      linkcolor=blue,
      unicode
      ]{hyperref}
\else
  \RequirePackage[
      ps2pdf,
      pagebackref=true,
      colorlinks=true,
      linkcolor=blue,
      unicode
      ]{hyperref}
\fi

\AtEndOfClass{%
  \AtBeginDocument{%
    \hypersetup{%
      breaklinks,
      baseurl       = http://,
      pdfpagemode   = None,
      colorlinks    = true,  
      anchorcolor   = blue,
      citecolor	    = blue, 
      filecolor	    = blue, 
      menucolor	    = blue,
      urlcolor	    = blue,
      pdfstartview  = XYZ,
      pdfstartpage  = 1,
      pdfauthor     = \FileAuthor,%
      pdftitle      = \FileTitle,%
      pdfsubject    = \FileSubject,%
      pdfkeywords   = \FileKeyWords,%
      pdfcreator    = \LaTeX,%
      pdfproducer   = \LaTeX}}}
      
\urlstyle{tt}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{************** Latex structure names redefinition ****************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\addto\captionsfrancais{%
  \renewcommand{\contentsname}%
    {Sommaire}%
}

\addto\captionsfrancais{%
  \renewcommand{\bibname}%
    {Bibliographie}%
}

\addto\captionsfrancais{%
  \renewcommand{\listtablename}%
    {Liste des Tableaux}%
}

\addto\captionsfrancais{%
  \renewcommand{\listfigurename}%
    {Liste des Figures}%
}

\addto\captionsfrancais{%
  \renewcommand{\indexname}%
    {Index Alphabétique}%
}

%\addto\captionsfrancais{%
%  \renewcommand{\chaptername}%
%    {}%
%}

%\addto\captionsfrancais{%
%  \renewcommand{\refname}%
%    {Références}%
%}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{********************* Loading new commands ***********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\newcommand{\shortcite}[1]{\cite{#1}}

\def\usebiblio#1{
  \gdef\@usebiblio{#1}
}
%\newcommand{\usebiblio}[1]{\newcommand{\@usebiblio}[1]{#1}}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\newcommand{\fhref}[2]{\href{#1}{#2}\footnote{\url{#1}}}

\newcommand{\shref}[3]{\href{#1}{#2}\cite{project-#3}}

\newcommand{\email}[1]{\href{mailto:#1}{#1}}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{********************* Defining custom colors *********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\definecolor{listinggray}{gray}{0.9}

\newcommand{\sommaire}{
  \typeout{ }
  \typeout{ }
  \typeout{================================================================}
  \typeout{******************* Adding table of content ********************}
  \typeout{================================================================}
  \typeout{ }
  \typeout{ }
  \cleardoublepage
  \tableofcontents
}

\newcommand{\import}[1]{
  \typeout{ }
  \typeout{ }
  \typeout{================================================================}
  \typeout{***                Including file #1.tex ...                 ***}
  \typeout{================================================================}
  \typeout{ }
  \typeout{ }
  \include{#1}
}

%%- Mise en page et style ------------------------------------------------------
\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{******************* Setting up fancy pagestyle *******************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\AtBeginDocument{
  \pagestyle{fancy}
  \lhead[\thepage]{}
  \rhead[]{\thepage}
  \lfoot[]{}
  \rfoot[]{}
  \cfoot[]{}
  %\selectlanguage{francais}
}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{******************* Suppress the Chapter word ********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \normalfont
\bfseries\Huge\thechapter.\ #1
\par\nobreak\vspace{40 pt}}}
\makeatother

%\makeatletter
%\renewcommand{\@makechapterhead}[1]{%
%\vspace*{50 pt}%
%{\setlength{\parindent}{0pt} \raggedright \normalfont
%\bfseries\Huge
%\ifnum \value{secnumdepth}>1 
%   \if@mainmatter\thechapter.\ \fi%
%\fi
%#1\par\nobreak\vspace{40 pt}}}
%\makeatother

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{******************* Setting up the page layout *******************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\paperwidth=210mm
\paperheight=297mm
\hoffset=-2cm
\voffset=-2cm
\textwidth=17cm
\textheight=25cm
\oddsidemargin=1.5cm
\evensidemargin=0.5cm
\headheight=0.5cm

\linespread{1.3}

%- Nouveau environnements -----------------------------------------------------
\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{********** Setting up the names of the new environments **********}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\newcommand{\acknowledgementsname}{Remerciements}
\newcommand{\introductionsname}{Introduction}
\newcommand{\conclusionsname}{Conclusion}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{*********** Setting up the acknowledgements environment **********}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\newenvironment{acknowledgements}
  {
    \thispagestyle{empty}
    \section*{\acknowledgementsname}
  }
  {
    \cleardoublepage
  }

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{************ Setting up the introduction environment *************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\newenvironment{introduction}
  {
    \phantomsection
    \addcontentsline{toc}{chapter}{\introductionsname}
    \chapter*{\introductionsname}
  }
  {
    \cleardoublepage
  }
  
\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{************* Setting up the conclusion environment **************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\newenvironment{conclusion}
  {
    \phantomsection
    \addcontentsline{toc}{chapter}{\conclusionsname}
    \chapter*{\conclusionsname}
  }
  {
    \cleardoublepage
  }


\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{************** Setting up the listing environment ****************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }
\lstset{ %
language=[ANSI]C,               % choose the language of the code
basicstyle=\scriptsize,         % the size of the fonts that are used for the code
numbers=left,                   % where to put the line-numbers
numberstyle=\footnotesize,      % the size of the fonts that are used for the line-numbers
stepnumber=1,                   % the step between two line-numbers. If it's 1 each line will be numbered
numbersep=5pt,                  % how far the line-numbers are from the code
keywordstyle=\color{blue},
%keywordstyle=\color{red}\bfseries\underbar,
%backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color}
%backgroundcolor=\color{lbcolor},
%backgroundcolor=\color{listinggray}
showspaces=false,               % show spaces adding particular underscores
showstringspaces=false,         % underline spaces within strings
showtabs=false,                 % show tabs within strings adding particular underscores
rulecolor=\color{blue},
%framerulecolor=\color{blue},
%frame=single,	                  % adds a frame around the code
frame=Tb,
%frame=trBL,
%frameround=tttt,
%frameround=trbl,
%tabsize=2,	                    % sets default tabsize to 2 spaces
caption=,                       % by default, there is no caption.
captionpos=b,                   % sets the caption-position to bottom
%breaklines=true,               % sets automatic line breaking
%breakatwhitespace=false,       % sets if automatic breaks should only happen at whitespace
title=\lstname,                 % show the filename of files included with \lstinputlisting; also try caption instead of title
%escapeinside={\%*}{*)},        % if you want to add a comment within your code
%commentstyle=\textit,
%morekeywords={*,...},          % if you want to add more keywords to the set
}

%%------------------------------------------------------------------------------

\AtEndDocument{
  \cleardoublepage
  \setcounter{page}{1}
  \pagenumbering{roman}
}

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{********************** Processing options ************************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

\def\@isthereanyopt{+}
\newcommand{\isthereanyopt}[1]{
  \if\@isthereanyopt+
    \gdef\@isthereanyopt{yes}
    \def\appendixname{Annexes}
    \addtocontents{toc}{\contentsline {chapter}{\appendixname}{}}
  \fi
  \addcontentsline{toc}{section}{#1}
}

% Options
\DeclareOption{biblio}{
  \typeout{* Option bibliography is selected... *}
  %\bibliographystyle{apalike}
  \bibliographystyle{taln2003-fr}
  \AtEndDocument{
    \typeout{ }
    \typeout{ }
    \typeout{==============================================================}
    \typeout{****************** Adding the bibliography *******************}
    \typeout{==============================================================}
    \typeout{ }
    \typeout{ }
    \cleardoublepage
    \bibliography{\@usebiblio}
  }
}
    
\DeclareOption{table}{
  \typeout{* Option table is selected... *}
  \AtEndDocument{
    \typeout{ }
    \typeout{ }
    \typeout{==============================================================}
    \typeout{****************** Adding list of tables *********************}
    \typeout{==============================================================}
    \typeout{ }
    \typeout{ }
    \cleardoublepage
    \listoftables
  }
}

\DeclareOption{figure}{
  \typeout{* Option figure is selected...}
  \AtEndDocument{
    \typeout{ }
    \typeout{ }    
    \typeout{==============================================================}
    \typeout{****************** Adding list of figures ********************}
    \typeout{==============================================================}
    \typeout{ }
    \typeout{ }
    \cleardoublepage
    \listoffigures
  }
}

\DeclareOption{index}{
  \typeout{* Option index is selected... *}
  \makeindex
  \AtEndDocument{
    \typeout{ }
    \typeout{ }    
    \typeout{==============================================================}
    \typeout{*********************** Adding index *************************}
    \typeout{==============================================================}
    \typeout{ }
    \typeout{ }
    \cleardoublepage
    \printindex
  }
}

\DeclareOption*{
  \ClassWarning{Option '\CurrentOption' non valide...}
}
\ProcessOptions\relax

\typeout{ }
\typeout{ }
\typeout{==================================================================}
\typeout{****************** End of options processing *********************}
\typeout{==================================================================}
\typeout{ }
\typeout{ }

%%
%% End of file `internship-report.cls'.
